import axios from "axios";

const port = 'http://localhost:3000'
export const getAll = async (keyword)=>{
    let data;
    if (keyword) {
        data = await axios.get(`${port}/book?keyword=${keyword}`)
    }else
    {
        data = await axios.get(`${port}/book`)
    }   
    return data.data
}
export const delItem = async (id)=>{
    let data = await axios.delete(`${port}/book/${id}`)
    return data.data
}
export const putItem = async (id,book)=>{
    let data = await axios.put(`${port}/book/${id}`,book)
    return data.data
}
export const postItem = async (book)=>{
    let data = await axios.post(`${port}/book`,book)
    return data.data
}

export const getById = async (id)=>{
    let data = await axios.get(`${port}/book/${id}`)
    return data.data
}

